package jellyfishumbrella.tikis;

import megamu.mesh.Region;
import megamu.mesh.Site;

import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;

import com.jellyfishumbrella.GL.AbstractGameLogic;
import com.jellyfishumbrella.GL.AbstractKeyboardMouse;
import com.jellyfishumbrella.GL.RendererGL;

/**
 * TODO Put here a description of what this class does.
 * 
 * @author 500441547.
 *         Created Sep 4, 2012.
 */
public class KeyboardMouse extends AbstractKeyboardMouse {
	public KeyboardMouse(RendererGL renderGL) {
		super("keyboardMouseThread", renderGL);
		System.out.println("keyboard repeat: " + Keyboard.areRepeatEventsEnabled());
	}

	@Override
	public void process() {
		currTime = AbstractGameLogic.getTime();
		if (Keyboard.isCreated()){
			keyboard();
			customKeyboard();
		}
		if (Mouse.isCreated()) {
			mouse();
			customMouse();
		}
	}

	public void customKeyboard() {
		if (Keyboard.isKeyDown(Keyboard.KEY_E) && (currTime - lastKeyTime) > this.keyDelayMillis){
			System.out.println("q'ing eruption");
			Site center = GameLogic.volcanoIsland.center;
			Region caldera = center.region;
			GameLogic.activityQ.add(GameLogic.volcanoIsland.new EruptActivity(GameLogic.volcanoIsland.center, Volcano.LAVA_AMOUNT));
			lastKeyTime = currTime;
		}
		if (Keyboard.isKeyDown(Keyboard.KEY_M) && (currTime - lastKeyTime) > this.keyDelayMillis){
			System.out.println("changing mode");
			GameLogic.volcanoIsland.cycleMode();
			lastKeyTime = currTime;
		}
		if (Keyboard.isKeyDown(Keyboard.KEY_P) && (currTime - lastKeyTime) > this.keyDelayMillis){
			System.out.println("processingMoundLists");
			GameLogic.volcanoIsland.processMoundLists();
			lastKeyTime = currTime;
		}
		if (Keyboard.isKeyDown(Keyboard.KEY_R) && (currTime - lastKeyTime) > this.keyDelayMillis){
			System.out.println("subdivide regions");
			GameLogic.volcanoIsland.makeRegion(GameLogic.volcanoIsland.center);
			lastKeyTime = currTime;
		}
		if (Keyboard.isKeyDown(Keyboard.KEY_T) && (currTime - lastKeyTime) > this.keyDelayMillis){
			System.out.println("changing surface");
			GameLogic.volcanoIsland.changeTestSurface(GameLogic.volcanoIsland.center);
			lastKeyTime = currTime;
		}
	}

	public void customMouse() {

	}
}
